home *** CD-ROM | disk | FTP | other *** search
/ Gamers Delight 2 / Gamers Delight 2.iso / Aminet / game / role / Ang261Lib.lha / src / rods.c < prev    next >
C/C++ Source or Header  |  1994-10-22  |  8KB  |  329 lines

  1. /*
  2.  * rods.c : rod code 
  3.  *
  4.  * Copyright (c) 1989 Andrew Astrand 1991 
  5.  *
  6.  * Do what you like with it 
  7.  *
  8.  * I will sucker! ~Ludwig 
  9.  */
  10.  
  11. #include "constant.h"
  12. #include "config.h"
  13. #include "types.h"
  14. #include "externs.h"
  15.  
  16. #ifdef USG
  17. #ifndef ATARIST_MWC
  18. #include <string.h>
  19. #endif
  20. #else
  21. #include <strings.h>
  22. #endif
  23.  
  24. /* Lets do all prototypes correctly.... -CWS */
  25. #ifndef NO_LINT_ARGS
  26. #ifdef __STDC__
  27. static int direction(int *);
  28. #else
  29. static int          direction();
  30. #endif
  31. #endif
  32.  
  33. static int 
  34. direction(dir)
  35. int *dir;
  36. {
  37.     if (get_dir(NULL, dir)) {
  38.     if (py.flags.confused > 0) {
  39.         msg_print("You are confused.");
  40.         do {
  41.         *dir = randint(9);
  42.         } while (*dir == 5);
  43.     }
  44.     return 1;
  45.     }
  46.     return 0;
  47. }
  48.  
  49.  
  50. /* Rods for the slaughtering                 */
  51. void 
  52. activate_rod()
  53. {
  54.     int32u              i;
  55.     register int        l, ident;
  56.     int                 item_val, j, k, chance, dir;
  57.     register inven_type *i_ptr;
  58.     register struct misc *m_ptr;
  59.  
  60.     free_turn_flag = TRUE;
  61.     if (inven_ctr == 0)
  62.     msg_print("But you are not carrying anything.");
  63.     else if (!find_range(TV_ROD, TV_NEVER, &j, &k))
  64.     msg_print("You are not carrying any rods.");
  65.     else if (get_item(&item_val, "Activate which rod?", j, k, 0)) {
  66.     i_ptr = &inventory[item_val];
  67.     free_turn_flag = FALSE;
  68.     ident = FALSE;
  69.     m_ptr = &py.misc;
  70.     chance = m_ptr->save + (stat_adj(A_INT) * 2) -
  71.         (int)((i_ptr->level > 70) ? 70 : i_ptr->level)
  72.         + (class_level_adj[m_ptr->pclass][CLA_DEVICE] * m_ptr->lev / 3);
  73.     if (py.flags.confused > 0)
  74.         chance = chance / 2;
  75.     if ((chance < USE_DEVICE) && (randint(USE_DEVICE - chance + 1) == 1))
  76.         chance = USE_DEVICE;   /* Give everyone a slight chance */
  77.     if (chance <= 0)
  78.         chance = 1;
  79.     if (randint(chance) < USE_DEVICE)
  80.         msg_print("You failed to use the rod properly.");
  81.     else if (i_ptr->timeout <= 0) {
  82.         i = i_ptr->flags;
  83.         k = char_row;
  84.         l = char_col;
  85.         switch (i) {
  86.           case RD_LT:
  87.         if (!direction(&dir))
  88.             goto no_charge;
  89.         msg_print("A line of blue shimmering light appears.");
  90.         light_line(dir, char_row, char_col);
  91.         ident = TRUE;
  92.         i_ptr->timeout = 9;
  93.         break;
  94.           case RD_ILLUME:
  95.         light_area(k, l, damroll(2, 8), 2);
  96.         ident = TRUE;
  97.         i_ptr->timeout = 30;
  98.         break;
  99.           case RD_AC_BLTS:       /* Acid , New */
  100.         if (!direction(&dir))
  101.             goto no_charge;
  102.         if (randint(10)==1)
  103.             line_spell(GF_ACID,dir,k,l,damroll(6,8));
  104.         else
  105.             fire_bolt(GF_ACID,dir,k,l,damroll(6,8));
  106.         ident = TRUE;
  107.         i_ptr->timeout = 12;
  108.         break;
  109.           case RD_LT_BLTS:       /* Lightning */
  110.         if (!direction(&dir))
  111.             goto no_charge;
  112.         if (randint(12)==1)
  113.             line_spell(GF_LIGHTNING, dir, k, l, damroll(3, 8));
  114.         else
  115.             fire_bolt(GF_LIGHTNING, dir, k, l, damroll(3, 8));
  116.         ident = TRUE;
  117.         i_ptr->timeout = 11;
  118.         break;
  119.           case RD_FT_BLTS:       /* Frost */
  120.         if (!direction(&dir))
  121.             goto no_charge;
  122.         if (randint(10)==1)
  123.             line_spell(GF_FROST, dir, k, l, damroll(5, 8));
  124.         else
  125.             fire_bolt(GF_FROST, dir, k, l, damroll(5, 8));
  126.         ident = TRUE;
  127.         i_ptr->timeout = 13;
  128.         break;
  129.           case RD_FR_BLTS:       /* Fire */
  130.         if (!direction(&dir))
  131.             goto no_charge;
  132.         if (randint(8)==1)
  133.             line_spell(GF_FIRE, dir, k, l, damroll(8, 8));
  134.         else
  135.             fire_bolt(GF_FIRE, dir, k, l, damroll(8, 8));
  136.         ident = TRUE;
  137.         i_ptr->timeout = 15;
  138.         break;
  139.           case RD_POLY:
  140.         if (!direction(&dir))
  141.             goto no_charge;
  142.         ident = poly_monster(dir, k, l);
  143.         i_ptr->timeout = 25;
  144.         break;
  145.           case RD_SLOW_MN:
  146.         if (!direction(&dir))
  147.             goto no_charge;
  148.         ident = speed_monster(dir, k, l, -1);
  149.         i_ptr->timeout = 20;
  150.         break;
  151.           case RD_SLEE_MN:
  152.         if (!direction(&dir))
  153.             goto no_charge;
  154.         ident = sleep_monster(dir, k, l);
  155.         i_ptr->timeout = 18;
  156.         break;
  157.           case RD_DRAIN:
  158.         if (!direction(&dir))
  159.             goto no_charge;
  160.         ident = drain_life(dir, k, l, 75);
  161.         i_ptr->timeout = 23;
  162.         break;
  163.           case RD_TELE:
  164.         if (!direction(&dir))
  165.             goto no_charge;
  166.         ident = teleport_monster(dir, k, l);
  167.         i_ptr->timeout = 25;
  168.         break;
  169.           case RD_DISARM:
  170.         if (!direction(&dir))
  171.             goto no_charge;
  172.         ident = disarm_all(dir, k, l);
  173.         i_ptr->timeout = 30;
  174.         break;
  175.           case RD_LT_BALL:
  176.         if (!direction(&dir))
  177.             goto no_charge;
  178.         fire_ball(GF_LIGHTNING, dir, k, l, 32, 2);
  179.         ident = TRUE;
  180.         i_ptr->timeout = 23;
  181.         break;
  182.           case RD_CD_BALL:
  183.         if (!direction(&dir))
  184.             goto no_charge;
  185.         fire_ball(GF_FROST, dir, k, l, 48, 2);
  186.         ident = TRUE;
  187.         i_ptr->timeout = 25;
  188.         break;
  189.           case RD_FR_BALL:
  190.         if (!direction(&dir))
  191.             goto no_charge;
  192.         fire_ball(GF_FIRE, dir, k, l, 72, 2);
  193.         ident = TRUE;
  194.         i_ptr->timeout = 30;
  195.         break;
  196.           case RD_AC_BALL:
  197.         if (!direction(&dir))
  198.             goto no_charge;
  199.         fire_ball(GF_ACID, dir, k, l, 60, 2);
  200.         ident = TRUE;
  201.         i_ptr->timeout = 27;
  202.         break;
  203.           case RD_MAPPING:
  204.         map_area();
  205.         ident = TRUE;
  206.         i_ptr->timeout = 99;
  207.         break;
  208.           case RD_IDENT:
  209.         ident_spell();
  210.         ident = TRUE;
  211.         i_ptr->timeout = 10;
  212.         break;
  213.           case RD_CURE:
  214.         if ((cure_blindness()) || (cure_poison()) ||
  215.             (cure_confusion()) || (py.flags.stun > 0) || (py.flags.cut > 0))
  216.             ident = TRUE;
  217.         if (py.flags.stun > 0) {
  218.             if (py.flags.stun > 50) {
  219.             py.misc.ptohit += 20;
  220.             py.misc.ptodam += 20;
  221.             } else {
  222.             py.misc.ptohit += 5;
  223.             py.misc.ptodam += 5;
  224.             }
  225.             py.flags.stun = 0;
  226.             ident = TRUE;
  227.             msg_print("Your head stops stinging.");
  228.         } else if (py.flags.cut > 0) {
  229.             py.flags.cut = 0;
  230.             ident = TRUE;
  231.             msg_print("You feel better.");
  232.         }
  233.         i_ptr->timeout = 888;
  234.         break;
  235.           case RD_HEAL:
  236.         ident = hp_player(500);
  237.         if (py.flags.stun > 0) {
  238.             if (py.flags.stun > 50) {
  239.             py.misc.ptohit += 20;
  240.             py.misc.ptodam += 20;
  241.             } else {
  242.             py.misc.ptohit += 5;
  243.             py.misc.ptodam += 5;
  244.             }
  245.             py.flags.stun = 0;
  246.             ident = TRUE;
  247.             msg_print("Your head stops stinging.");
  248.         }
  249.         if (py.flags.cut > 0) {
  250.             py.flags.cut = 0;
  251.             ident = TRUE;
  252.             msg_print("You feel better.");
  253.         }
  254.         i_ptr->timeout = 888;
  255.         break;
  256.           case RD_RECALL:
  257.         if (py.flags.word_recall == 0) {
  258.             py.flags.word_recall = 15 + randint(20);
  259.             msg_print("The air about you becomes charged...");
  260.         } else {
  261.             py.flags.word_recall = 0;
  262.             msg_print("A tension leaves the air around you...");
  263.         }
  264.         ident = TRUE;
  265.         i_ptr->timeout = 60;
  266.         break;
  267.           case RD_PROBE:
  268.         probing();
  269.         ident = TRUE;
  270.         i_ptr->timeout = 50;
  271.         break;
  272.           case RD_DETECT:
  273.         detection();
  274.         ident = TRUE;
  275.         i_ptr->timeout = 99;
  276.         break;
  277.           case RD_RESTORE:
  278.         if (restore_level() || res_stat(A_STR) || res_stat(A_INT) ||
  279.             res_stat(A_WIS) || res_stat(A_DEX) || res_stat(A_CON) ||
  280.             res_stat(A_CHR))
  281.             ident = TRUE;
  282.         i_ptr->timeout = 999;
  283.         break;
  284.           case RD_SPEED:
  285.         if (py.flags.fast == 0)
  286.             ident = TRUE;
  287.         py.flags.fast += randint(30) + 15;
  288.         i_ptr->timeout = 99;
  289.         break;
  290.           case RD_TRAP_LOC:
  291.         if (detect_trap())
  292.             ident = TRUE;
  293.         i_ptr->timeout = 99;    /* fairly long timeout because rod so
  294.                      * low lv -CFT */
  295.         break;
  296. #if 0
  297.           case RD_MK_WALL:       /* JLS */
  298.         if (!direction(&dir))
  299.             goto no_charge;
  300.         ident = build_wall(dir, k, l);
  301.         i_ptr->timeout = 999;    /* don't want people to abuse this
  302.                      * -JLS */
  303.         break;
  304. #endif
  305.           default:
  306.         msg_print("Internal error in rods() ");
  307.         break;
  308.         }
  309.         if (ident) {
  310.         if (!known1_p(i_ptr)) {
  311.             m_ptr = &py.misc;
  312.         /* round half-way case up */
  313.             m_ptr->exp += (i_ptr->level + (m_ptr->lev >> 1)) /
  314.             m_ptr->lev;
  315.             prt_experience();
  316.  
  317.             identify(&item_val);
  318.             i_ptr = &inventory[item_val];
  319.         }
  320.         } else if (!known1_p(i_ptr)) {
  321.         sample(i_ptr);
  322.         }
  323.     no_charge:;
  324.     } else {
  325.         msg_print("The rod is currently exhausted.");
  326.     }
  327.     }
  328. }
  329.